import sys

def check_dependency(package_name, import_name=None):
    """检查指定包的安装状态"""
    if import_name is None:
        import_name = package_name
    
    try:
        if package_name == 'scikit-learn':
            import sklearn
            version = sklearn.__version__
            package_name = 'sklearn'
        else:
            exec(f"import {import_name}")
            module = eval(import_name)
            version = getattr(module, '__version__', 'unknown')
        
        print(f"✅ {package_name:15} v{version}")
        return True
    except ImportError:
        print(f"❌ {package_name:15} 未安装")
        return False
    except Exception as e:
        print(f"⚠️  {package_name:15} 错误: {str(e)[:50]}")
        return False

print("=" * 60)
print("完整依赖检查")
print("=" * 60)

# 检查所有必需的依赖
dependencies = [
    ("numpy", "np"),
    ("pandas", "pd"), 
    ("matplotlib", "plt"),
    ("seaborn", "sns"),
    ("scikit-learn", None),
    ("lightgbm", "lgb")
]

all_installed = True
for pkg, import_name in dependencies:
    if not check_dependency(pkg, import_name):
        all_installed = False

print("=" * 60)
if all_installed:
    print("✅ 所有依赖已正确安装！")
else:
    print("❌ 部分依赖未安装，请运行: pip install numpy pandas matplotlib seaborn scikit-learn lightgbm")
print("=" * 60)